package com.dycx.api.controller.manage.user;

import com.dycx.common.RestResponse;
import com.dycx.common.annotation.WriterLog;
import com.dycx.common.enums.BizTypeEnum;
import com.dycx.user.dto.CreditRecordDTO;
import com.dycx.user.enums.CreditRecordEnum;
import com.dycx.user.service.CreditRecordService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;


@RestController
@RequestMapping(value = "/manage/user/credit")
public class CreditController {

    @Resource
    private CreditRecordService creditRecordService;

    /**
     * 添加
     **/
    @WriterLog(bizType = BizTypeEnum.USER_ACCOUNT, bizValue = "{#creditRecordDto.uid}")
    @PostMapping("/updateCredit")
    public RestResponse<?> updateCredit(@RequestBody @Valid CreditRecordDTO creditRecordDto) {
        creditRecordDto.setType(CreditRecordEnum.CREDIT_RECORD_ADMIN.getCode());
        return RestResponse.success(creditRecordService.updateCredit(creditRecordDto));
    }

    /**
     * 查询 分页查询
     **/
    @PostMapping("/getPage")
    public RestResponse<?> getPage(@RequestBody CreditRecordDTO creditRecordDTO) {
        return RestResponse.success(creditRecordService.getPage(creditRecordDTO));
    }


}
